'use client'
import React, { useState } from "react"
import './index.scss'
import { FileTextOutlined, FileDoneOutlined } from '@ant-design/icons';
import { useRouter } from 'next/navigation'

interface SideruiProps {
    name: string;
    description: string;
    setData: (type: string) => void;
}

const Siderui: React.FC<SideruiProps> = ({ name, description, setData }) => {

    const router = useRouter()
    const list = [
        { name: '文档', icon: <FileTextOutlined />, type: 'doc' },
        { name: '政策查询', icon: <FileDoneOutlined />, type: 'ply' }
    ]
    const [active, setactive] = useState(0)
    return (
        <div className="siderui">
            <div className='siderui_icon'>
                <img src="/word.svg" alt="" />
            </div>
            <div className="return" onClick={() => { router.push('/pages/home') }}>
                返回
            </div>
            <div className="siderui_text">
                {name}
            </div>
            <div className="siderui_description">
                {description}
            </div>
            <div className="option">
                {
                    list.map((item: any, index: number) => {
                        return <div className={active == index ? 'active' : ''} key={index} onClick={() => {
                            setactive(index)
                            setData(item.type)
                        }}>{item.icon}&nbsp;&nbsp;{item.name}</div>
                    })
                }
            </div>
        </div>
    )

}

export default Siderui

